package io.renren.modules.business.controller;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

import io.renren.modules.business.entity.BusProjectTutorEntity;
import io.renren.modules.business.service.BusProjectTutorService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;

/**
 * 项目导师管理
 *
 * @author liao mengqing
 */
@RestController
@RequestMapping("business/tutor")
public class BusProjectTutorController {
    @Autowired
    private BusProjectTutorService busProjectTutorService;

    /**
     * 查询导师列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("business:tutor:list")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = busProjectTutorService.queryPage(params);
        return R.ok().put("page", page);
    }

    /**
     * 获取导师列表信息
     * @return
     */
    @RequestMapping("/select")
    @RequiresPermissions("business:tutor:select")
    public R select(){
        List<Map<String, Object>> list = busProjectTutorService.selectTutor();
        return R.ok().put("tutorList", list);
    }

    /**
     * 查询未被添加为项目导师的教师信息
     * @param params
     * @return
     */
    @RequestMapping("/teacher")
    @RequiresPermissions("business:tutor:teacher")
    public R teacher(@RequestParam Map<String, Object> params) {
        PageUtils page = busProjectTutorService.queryTeacher(params) ;
        return R.ok().put("page", page);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("business:tutor:save")
    public R save(@RequestBody BusProjectTutorEntity busProjectTutor){
		busProjectTutorService.save(busProjectTutor);
        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("business:tutor:delete")
    public R delete(@RequestBody Long[] tutorIds){
		busProjectTutorService.removeByIds(Arrays.asList(tutorIds));
        return R.ok();
    }

}
